﻿using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ArduinoSharp.Lib
{
    public class SerialPortConfig
    {
        public bool isValid { get; set; }
        public string PortName { get; set; }
        public int BaudRate { get; set; }
        public int DataBits { get; set; }
        public StopBits StopBits { get; set; }
        public Parity Parity { get; set; }
        public int ReadTimeout { get; set; }
        public int WriteTimeout { get; set; }

        public void SetToPort(SerialPort port)
        {
            if (!isValid)
            {
                throw new ArgumentException("SerialPortConfig is not valid");
            }
            port.PortName = this.PortName;
            port.BaudRate = this.BaudRate;
            port.DataBits = this.DataBits;
            port.StopBits = this.StopBits;
            port.Parity = this.Parity;
            port.ReadTimeout = this.ReadTimeout;
            port.WriteTimeout = this.WriteTimeout;

        }

    }

}
